<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>统计字符串</title>


    <script>
        var str = new String('awdoawdawoasfasocawsoafw');

        var index = new Array();
        var sum = 0;
        var len = str.indexOf('o');
        while (len != -1) {
            index.push(len);
            sum++;
            len = str.indexOf('o', len + 1);
        }
        console.log(index, sum);
    </script>






</head>

<body>

</body>

</html>